home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_59_Cycle Me Click.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.7 KB  |  94 lines

  1. property enabled, membermin, membermax, ImageCastLib, CycleStyle, tracking, goingDown, CurrentState, numstates, name
  2.  
  3. on mouseUp me
  4.   bumpstate_intern(me)
  5. end
  6.  
  7. on setstate me, statenum
  8.   if the enabled of me then
  9.     if statenum > the numstates of me then
  10.       set statenum to the numstates of me
  11.     else
  12.       if statenum < 1 then
  13.         set statenum to 1
  14.       end if
  15.     end if
  16.     set the member of sprite the spriteNum of me to member (the membermin of me + statenum - 1) of castLib ImageCastLib
  17.   end if
  18. end
  19.  
  20. on setGoingDown me, value
  21.   set the goingDown of me to value
  22. end
  23.  
  24. on SetCycleStyle me, value
  25.   set the CycleStyle of me to value
  26. end
  27.  
  28. on bumpstate_intern me
  29.   if the enabled of me then
  30.     if the CycleStyle of me = #repeat then
  31.       if not (the goingDown of me) then
  32.         set curr to the CurrentState of me + 1
  33.         if curr > the numstates of me then
  34.           set curr to 1
  35.         end if
  36.       else
  37.         set curr to the CurrentState of me - 1
  38.         if curr < 1 then
  39.           set curr to the numstates of me
  40.         end if
  41.       end if
  42.     else
  43.       if not (the goingDown of me) then
  44.         set curr to the CurrentState of me + 1
  45.         if curr > the numstates of me then
  46.           set curr to curr - 2
  47.           set the goingDown of me to 1
  48.         end if
  49.       else
  50.         set curr to the CurrentState of me - 1
  51.         if curr < 1 then
  52.           set curr to 2
  53.           set the goingDown of me to 0
  54.         end if
  55.       end if
  56.     end if
  57.     set the CurrentState of me to curr
  58.     setstate(me, curr)
  59.   end if
  60. end
  61.  
  62. on beginSprite me
  63.   set tracking to 0
  64.   set membermin to the memberNum of member membermin
  65.   set membermax to the memberNum of member membermax
  66.   puppetSprite(the spriteNum of me, 1)
  67.   set the enabled of me to 1
  68.   set the numstates of me to the membermax of me - the membermin of me + 1
  69.   set the CurrentState of me to the memberNum of sprite the spriteNum of me - the membermin of me + 1
  70.   set the ImageCastLib of me to the number of castLib the castLibNum of sprite the spriteNum of me
  71.   setstate(me, the CurrentState of me)
  72. end
  73.  
  74. on endSprite me
  75.   puppetSprite(the spriteNum of me, 0)
  76. end
  77.  
  78. on getPropertyDescriptionList
  79.   set p_list to [#name: [#comment: "Item Name:", #format: #symbol, #default: #MultiState_1], #membermin: [#comment: "First Image:", #format: #member, #default: member 1], #membermax: [#comment: "Last Image:", #format: #member, #default: member 1], #CycleStyle: [#comment: "Cycle Style:", #format: #symbol, #range: [#repeat, #Reverse], #default: #repeat], #goingDown: [#comment: "Reverse Order:", #format: #boolean, #default: 0]]
  80.   return p_list
  81. end
  82.  
  83. on getBehaviorDescription
  84.   return "Prepares a sprite to use a Series of adjacent Bitmap castmembers to represent an set of mutually exclusive states that the user can cycle through.  See below for usage.  " & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Item Name - ( optional ) name of this control." & RETURN & "ΓÇó First Image - number of first castmember in the sequence." & RETURN & "ΓÇó Last Image  - number of last castmember in the sequence." & RETURN & "ΓÇó Cycle Mode - specifies how images in cycle are repeated on subsequent iterations. The Repeat mode repeats the same sequence.  The Reverse mode cycles back through the sequence in reverse order." & RETURN & "ΓÇó Reverse Order - proceed from last to first image by default." & RETURN & "MESSAGES:" & RETURN & "ΓÇó CycleState - advance to the next image in the sequence, or the previous image, if the GoingDown property is true. & RETURN & "ΓÇó SetState state_number - advance directly to position state_number in the sequence."
  85. end
  86.  
  87. on getAssocMembers
  88.   set myPropList to []
  89.   repeat with x = membermin + 1 to membermax
  90.     add(myPropList, member x of castLib ImageCastLib)
  91.   end repeat
  92.   return myPropList
  93. end
  94.